package cur.nature.admin.controller;

import cur.nature.admin.service.Admin_ResourceService;
import cur.nature.framework.mvc.base.BaseAPI;
import cur.nature.framework.mvc.crud.CrudController;
import cur.nature.admin.model.vo.Admin_ResourceVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 资源管理表 Controller
 * 作者：Auto Generator By wujian
 * 生成日期：2023-07-09 18:17:16
 */
@Tag(name = "资源管理 接口")
@RestController
@RequestMapping("admin/v1/api/Admin_Resource")
public class Admin_ResourceController extends CrudController<Admin_ResourceService> {
    public Admin_ResourceController(Admin_ResourceService baseService) {
        super(baseService);
    }

    @Operation(summary = "查询 资源管理")
    @PostMapping("/list")
    public Admin_ResourceVO.list_Result list(@Valid @RequestBody Admin_ResourceVO.list_Param param) throws Exception {
        Admin_ResourceVO.list_Result list = getService().list(param);
        return list;
    }

    @Operation(summary = "更新 资源管理")
    @PostMapping("/operate")
    public BaseAPI.SaveResult<Admin_ResourceVO> save(@Valid @RequestBody List<Admin_ResourceVO> param) throws Exception {
        int rows = getService().saveList(param);
        BaseAPI.SaveResult result = new BaseAPI.SaveResult();
        result.setRows(rows);
        result.setObject(rows == 0 ? null : param);
        return result;
    }

}
